package com.nuoniu.sibanyun.controller.crm.call;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.crm.call.CrmCallBaseSetting;
import com.nuoniu.sibanyun.entity.crm.call.dto.CrmCallBaseSettingSearchDto;
import com.nuoniu.sibanyun.service.crm.call.ICrmCallBaseSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 客户管理-外呼套餐 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/crm/callBaseSetting")
@Api(value="外呼套餐 ",tags={"外呼套餐"})
public class CrmCallBaseSettingController extends BaseController {

    @Autowired
    private ICrmCallBaseSettingService crmCallBaseSettingService;


    @PostMapping("pageCrmCallBaseSetting")
    @ApiOperation(value = "分页查询 套餐")
//    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult pageCrmCallBaseSetting(@RequestBody CrmCallBaseSettingSearchDto crmCallBaseSettingSearchDto) {
        return HttpResult.ok(crmCallBaseSettingService.pageCrmCallBaseSetting(crmCallBaseSettingSearchDto));
    }

    @PostMapping("saveCrmCallBaseSetting")
    @ApiOperation(value = "保存 套餐")
    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult saveCrmCallBaseSetting(@RequestBody CrmCallBaseSetting crmCallBaseSetting){
        crmCallBaseSettingService.saveCrmCallBaseSetting(crmCallBaseSetting);
        return HttpResult.ok();
    }

    @PostMapping("deleteByIds")
    @ApiOperation(value = "批量删除")
    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult deleteByIds(@RequestBody List<Long> ids){
        crmCallBaseSettingService.deleteByIds(ids);
        return HttpResult.ok();
    }

    @PostMapping("batchEnable")
    @ApiOperation(value = "批量启用")
    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult batchEnable(@RequestBody List<Long> ids){
        crmCallBaseSettingService.batchEnable(ids);
        return HttpResult.ok();
    }

    @PostMapping("batchDisable")
    @ApiOperation(value = "批量暂停")
    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult batchDisable(@RequestBody List<Long> ids){
        crmCallBaseSettingService.batchDisable(ids);
        return HttpResult.ok();
    }

    @PostMapping("saveBaseSettingOrder")
    @ApiOperation(value = "新购/变更 套餐")
    public HttpResult saveBaseSettingOrder(Long baseSettingId){
        crmCallBaseSettingService.saveBaseSettingOrder(baseSettingId);
        return HttpResult.ok();
    }


}
